package com.demo.docker.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;
import java.util.Map;

@RestController
public class DemoController {

    @Value("${server.port:8080}")
    private int appPort;
    @Value("${spring.application.name:}")
    private String appName;
    @Value("${demo.arg0:}")
    private String demoArg0;
    @Value("${demo.arg1:}")
    private String demoArg1;

    @PostMapping("/hello")
    public Object hello(@RequestBody Map<String,String> requestBody, @RequestParam Map<String,String> requestParam){
        Map<String,Object> result = new LinkedHashMap<>();
        result.put("code","0");
        result.put("message","hello");
        result.put("requestBody",requestBody);
        result.put("requestParam",requestParam);

        Map<String,Object> env = new LinkedHashMap<>();
        env.put("appPort",appPort);
        env.put("appName",appName);
        env.put("demoArg0",demoArg0);
        env.put("demoArg1",demoArg1);
        result.put("env",env);

        return result;
    }

}
